#    This file is part of django_ip2country.
#    django_ip2country is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    django_ip2country is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with django_ip2country.  If not, see <http://www.gnu.org/licenses/>.
#    Author: Esteban Feldman esteban.feldman@gmail.com


import bigint_patch

from django.db import models


class Ip2Country(models.Model):
    #ip_from = models.PositiveIntegerField()
    #ip_to = models.PositiveIntegerField()
    ip_from = bigint_patch.BigIntegerField()
    ip_to = bigint_patch.BigIntegerField()
    
    country_code2 = models.CharField(max_length = 2)
    country_code3 = models.CharField(max_length = 3)
    country_name = models.CharField(max_length = 50)     

    class Meta:
        ordering = ['ip_from']
        
    def __unicode__(self):
        return "%s %s %s" % (self.ip_from ,self.ip_to, self.country_name)
    

